from appium import webdriver
from appium.options.android import UiAutomator2Options

from base.basepage import BasePage


class XueQiu(BasePage):

    def start(self):
        # 初始化
        caps = {
            "platformName": "android",
            "appium:automationName": "uiautomator2",
            "appium:deviceName": "127.0.0.1:7555",
            "appium:appPackage": "com.xueqiu.android",
            "appium:appActivity": ".view.WelcomeActivityAlias",
            "appium:noReset": True,
            "appium:forceAppLaunch": True
        }

        self.driver = webdriver.Remote("http://localhost:4723",
                                       options=UiAutomator2Options().load_capabilities(caps))
        self.wait_im()
        return self

    def end(self):
        # 退出
        self.quit()

    def go_pages(self):
        # 进入应用
        from app_po.page.main_page import Main
        return Main(self.driver)
